<!DOCTYPE html>
  <html>
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
      <title>title</title>
      <link rel="stylesheet" type="text/css" href="../css/api.css"/>
      <style>
      body{
        width: 100%;
        height: 100%;
        /*padding-top: 1.7rem;*/
      }
      .header{
            width: 93%;
            height: 2.5rem;
            line-height: 2.5rem;
            padding: 0.5rem 0.8rem;
            text-align: center;
            position: fixed;
            /*padding-top: 1.7rem;*/
            background-color: #40cccc;
            z-index: 999;
        }
      .header_img{
        width: 7%;
        height:60%;
        /*float: left;*/
        margin-top: 0.6rem;
      }
      .header_img img{
        width: 100%;
        height: 100%;
      }
      .header h3{
        line-height: 3rem;
        width: 90%;
        /*border: 0.1rem solid red;*/
        margin-left: 0.7rem;
        text-align: center;
        font-weight: bold;
        color: #fff;
      }
      .fl{
        float: left;
      }
      .fr{
        float: right;
      }
      .math{
        width: 93%;
        height: 100%;
      position: absolute;
        /*margin-top:2rem;*/
        top: 3.7rem;
        padding:1rem 0.8rem;
        overflow: scroll;
        bottom: 5rem;
      }
      .math_one{
        width:93%;
        height:10%;
        min-height: 3rem;
        background-color: rgb(242, 242, 242, 0.5);
        margin-bottom: 1rem;
        border-radius: 0.5rem;
        padding: 0.5rem 0.8rem;

      }
      .one_o{
        width: 95%;
        height:10%;

        position: relative;
      }
      .math_left{
        width: 100%;
        height: 100%;
      font-size: 0.9rem;

      }
      .left_p{
        position: absolute;
        top: 3.7rem;
        font-size: 0.8rem;
        color: #51321a;

      }
      .math_right{


        width: auto;
        height: 1.5rem;
        text-align: center;
        line-height: 1.5rem;
        color: #fff;
        font-size: 0.8rem;
        position: absolute;
        bottom: -4.5rem;
        right:-1.5rem;

      }
      .math_right p{
          background-color:#40cccc;
        margin-left: 0.3rem;
        border-radius: 0.3rem;
        padding: 0rem 0.15rem;

      }

      .p1{
        /*font-weight: bold;*/
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp:3;
        -webkit-box-orient:vertical;
      }

      </style>
  </head>
  <body>
    <div class="header">
      <div class="header_img fl" onclick="tc()">
          <img src="../image/tc.png" alt="" >
      </div>
      <div class="header_img fr" onclick="get_some()">
          <img src="../image/sx.png" alt="">
      </div>
      <h3>课程管理</h3>

    </div>
    <!-- 内容 -->
    <div class="math" id="cur_list">

    </div>
  </body>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/common.js"></script>
  <script type="text/javascript" src="../script/jquery-1.8.3.js"></script>

  <script type="text/javascript">
  var userinfo = $api.getStorage('userinfo');
  var ry_token = $api.getStorage('ry_token');
      apiready = function(){
        //alert(ry_token)
        if(!userinfo){
          login_at()
        }else{
          get_some()
        }
        api.addEventListener({
            name:'user_login',
            extra:{
                threshold:0
            }
        }, function(ret, err){
          userinfo = $api.getStorage('userinfo');
          get_some()
        });
        api.addEventListener({
            name:'fbzy',
            extra:{
                threshold:0
            }
        }, function(ret, err){
        //  userinfo = $api.getStorage('userinfo');
          get_some()
        });

      };
      function tc(){
        api.confirm( {
          title: '提示',
          msg: '确定退出当前账号?',
          buttons: [ '确定', '取消' ]
        }, function ( ret, err ) {
          var index = ret.buttonIndex;
          if ( index == 1 ) {
            $api.clearStorage()
            login_at()
          }
        })
      }
      function get_some() {
        if(!userinfo){
          login_at()
        }
        var html =''
        var obj = $api.byId('cur_list');

        api.ajax({
            url: SITE_URL+'livebr/cur/see',
            method: 'post',
            data: {
                values: {
                    cur_id: userinfo.cur_id
                }
            }
        },function(ret, err){
            if (ret) {
              if(ret.error==200){
                if(ret.data.length>0){
                  for (var i = 0; i < ret.data.length; i++) {
                    var dat = ret.data[i]
                      //alert( JSON.stringify( dat ) );
                    html +='<div class="math_one">'
                    html +='<div class="one_o">'
                    html +='<div class="math_left fl">'
                    if(dat.type==1){
                    html +='<p class="p1">'+dat.section+':'+dat.name+'<br/>允许开播时间:'+dat.kb_time+'</p>'
                    }else{
                      html +='<p class="p1">'+dat.section+':'+dat.name+'</p>'
                    }

                    html +='<p class="left_p">上课:'+dat.start_time+'</p>'
                    html +='</div>'
                    html +='<div class="math_right">'
                    if(dat.type==1){
                      if(dat.kb==1){
                        html +='<p class="fl" onclick="liveing('+dat.id+')">开始直播</p>'
                      }
                    }


                    if(dat.fbzz==1){
                      html +='<p class="fl" onclick="fbzy('+dat.id+')">发布作业</p>'
                    }else{
                      html +='<p class="fl" onclick="zyxq('+dat.id+')">已发布</p>'
                    }

                    html +='<p class="fl" onclick="zylist('+dat.id+')"> 作业 </p>'
                    html +='</div>'
                    html +='</div>'
                    html +='</div>'
                  }
                  $api.html(obj, html);

                }
              }else{
                msgcode('暂无需要上课的章节')
              }
                //alert( JSON.stringify( ret ) );
            } else {
              msgcode('请检查网络连接')
                //alert( JSON.stringify( err ) );
            }
        });

      }

      function fbzy(id) {
        api.openWin({
            name: 'releace',
            url: './releace.html',
            pageParam: {
                id: id,

            }
        });
      }
      function zylist(id) {
        api.openWin({
            name: 'zy_list',
            url: './zy_list.html',
            pageParam: {
                id: id,

            }
        });
      }
      function liveing(id) {
        api.openWin({
            name: 'liveing',
            url: './liveing.html',
            pageParam: {
                id: id,

            }
        });
      }
      function zyxq(id) {
        api.openWin({
            name: 'zyxq',
            url: './zyxq.html',
            pageParam: {
                id: id,

            }
        });
      }
  </script>
  </html>
